package com.camtc.camcenter.redis;

import com.camtc.camcenter.util.PropertyUtils;

import static com.camtc.camcenter.common.CamConstants.SPLIT_STR;

/**
 * <p>
 * Redis键名规则
 * </p>
 *
 * @author chentianshun
 * @since 2021-07-28
 */
public class RedisKeyRule {

    private static final String COMMON_KEY = "cam_center.redis_key";

    private static final String LOGIN_KEY = "VARIFY:LOGIN:KEY";

    /**
     * 登录Redis键
     *
     * @param verifyCode
     * @return
     */
    public static String getLoginVerifyKey(String verifyCode) {
        return getCommonKey(LOGIN_KEY).append(SPLIT_STR).append(verifyCode).toString();
    }

    /**
     * 获取Redis统一开头
     *
     * @param key
     * @return
     */
    private static StringBuilder getCommonKey(String key) {
        StringBuilder rtnSb = new StringBuilder(PropertyUtils.getProperty(COMMON_KEY));
        rtnSb.append(SPLIT_STR).append(key);
        return rtnSb;
    }
}
